package com.onpositive.units;

import java.util.ArrayList;

import org.w3c.dom.Element;

import com.onpositive.knowledge.model.values.IHasValue;

public class ParsedSentence extends ParsedValueSequenceV2 {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7560604935191502078L;
	public static final String ID = "sentence" ;

//	public ParsedSentence(ParsedTerm[] valuesArray, String comment) {
//		super(valuesArray, comment);
//	}
	public ParsedSentence(ParsedValue[] valuesArray, String comment, String[] prefixAdnPostfix) {
		super(valuesArray, comment, prefixAdnPostfix);
	}
	
	public ParsedSentence( ParsedValue pv, String comment )
	{
		super( pv, comment ) ;		
	}

	public ParsedSentence(Element element) {
		super(element);
	}
	
	protected ParsedSentence( ParsedSentence other, Object[] valArr, String comment )
	{
		super( other, valArr, comment ) ;		
	}
	
	@Override
	public String getId() {
		return ID;
	}
	
	@Override
	public String getValueAsString() {

		StringBuilder builder = new StringBuilder();

		if (valuesArray.length == 0)
			return "";

		for (ParsedValue pv : valuesArray) {
			builder.append(pv.getValueAsString());
			builder.append(" ");
		}
		builder.delete(builder.length() - 1, builder.length());
		return builder.toString();
	}
	
	@Override
	public IHasValue clone(Object value, String comment) {
		if( !(value instanceof ParsedValue[]) )
			return null;
		
		if( comment == null )
			comment = this.getComment() ;
		
		ParsedValue[] valArr = (ParsedValue[]) value ;
		return new ParsedSentence( this, valArr, comment ) ;		
	}

}
